python中判断字符串是否为空的方法 变量为字符串类型(优雅的方式) if not string: print('not empty') else: print('empty') 变量类型不确定 if string == '': print('not empty') else: print('empty') 推荐学习《python教程》。