1. r string: (Ref:https://stackoverflow.com/questions/2953834/windows-path-in-python)
What is the best way to represent a Windows directory, for example
"C:\meshes\as"
?
you can use always:
'C:/mydir'
this works both in linux and windows. Other posibility is
'C:\\mydir'
if you have problems with some names you can also try raw string literals:
r'C:\mydir'
(在C#中,如針對Path, 可用@"path")
2. f string (Ref:medium.com)
可用 f-string 改成如下格式(在C#, 請用$"string{variable}"),就可以將之前的變量帶入並格式化輸出喔!:f"I am {first_name} {middle_name}. {last_name}"
沒有留言:
張貼留言