【问题标题】:Can I put a comment in between a line of code in python without commenting the whole line? [duplicate]我可以在python中的一行代码之间添加注释而不注释整行吗? [复制]
【发布时间】:2021-08-17 11:24:10
【问题描述】:

我现在正在使用 thonny,但总的来说我想知道我可以在 python 中的一行代码之间进行评论

from tkinter import *
root=Tk()

mybutton=Button(root,text="click Help",state=DISABLED,padx=60,pady=55) 
mybutton.pack()
root.mainloop()                                                                                    

我想在这里评论 state=disabled 但不是整行。所以我可以这样做还是我必须为它写一个新行。 :)

【问题讨论】:

    标签: python python-3.x


    【解决方案1】:

    你可以把参数放在多行,然后注释你不想要的那一行:

    from tkinter import *
    root=Tk()
    
    mybutton = Button(
        root,
        text="click Help",
        #state=DISABLED,
        padx=60,
        pady=55
    ) 
    mybutton.pack()
    root.mainloop()                                                                                    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 2020-10-15
      • 2017-07-07
      • 2016-11-04
      • 2011-04-24
      • 2021-11-03
      • 1970-01-01
      相关资源
      最近更新 更多