範例看不明...
python吧
全部回复
仅看楼主
level 11
喵喵陳 楼主
FONT_NAMES = ",".join(
str(x)
for x in [
"notosanscjktcregular",
"notosansmonocjktcregular",
"notosansregular,",
"microsoftjhengheimicrosoftjhengheiuilight",
"microsoftyaheimicrosoftyaheiuilight",
"msgothicmsuigothicmspgothic",
"msmincho",
"Arial",
]
)
為什麼要加str(x)然後解釋x是
[
"notosanscjktcregular",
"notosansmonocjktcregular",
"notosansregular,",
"microsoftjhengheimicrosoftjhengheiuilight",
"microsoftyaheimicrosoftyaheiuilight",
"msgothicmsuigothicmspgothic",
"msmincho",
"Arial",
]這list?而不是只把這list放入join()
2024年03月09日 09点03分 1
level 11
喵喵陳 楼主
其實也很不明白為什麼FONT_NAMES不用list而用str...不過未拆解到那步......難道是因為index不存在元素會報錯find就不會?
2024年03月09日 09点03分 2
level 11
喵喵陳 楼主
至於"notosansregular,"的,...應該是沒影響的手誤所以沒發現/處理?
2024年03月09日 09点03分 3
吧务
level 12
多此一举的写法
2024年03月09日 09点03分 4
level 1
万一不是字符串怎么办?
2024年03月09日 18点03分 5
@喵喵陳 我个人觉得是为了规范,有些BUG就是不小心造成的,万一你少打个引号也是有可能的啊
2024年03月10日 15点03分
level 12
直接将 [] 放到join里就行
2024年03月10日 05点03分 6
我就是單純不明白而不是不會....為什麼不直接把list放入去而要先定義了x是str再解釋x是那[]這樣複雜......畢竟還有def fun(para:str)->None:這麼複雜(而多餘)的東西例如非必須的->None跟完全沒用的:str等「為什麼」要放...
2024年03月10日 09点03分
level 7
直接放在join里就行
FONT_NAMES = ",".join([
"notosanscjktcregular",
"notosansmonocjktcregular",
"notosansregular,",
"microsoftjhengheimicrosoftjhengheiuilight",
"microsoftyaheimicrosoftyaheiuilight",
"msgothicmsuigothicmspgothic",
"msmincho",
"Arial",
])
2024年03月10日 06点03分 7
level 11
喵喵陳 楼主
崩潰中......查了一個周未終於搞明
def的para後的:xxx叫typing,功用其實是remark也就是平時在#後面的內容......好吧,這是給呼叫函式的外部程式看的remark....
->應該也是差不多的東西....[天旋地轉中......],不過還沒查到名稱...@@
2024年03月11日 01点03分 8
1