Python errors All In One
Python errors All In One
SyntaxError: invalid character in identifier

\u200b, ZERO WIDTH SPACE
https://stackoverflow.com/questions/14844687/invalid-character-in-identifier
SyntaxError: invalid syntax
if__name__ == "__main__":
# if 关键字,后面加空格
if __name__ == "__main__":

用于区分,如何执行 Python 模块

https://www.jcchouinard.com/python-if-name-equals-main/
# Python program to execute
# main directly
print ("Always executed")
if __name__ == "__main__":
# 模块, 被直接执行的时候
print ("Executed when invoked directly")
else:
# 模块,被 import 使用的时候
print ("Executed when imported")
https://www.geeksforgeeks.org/what-does-the-if-name-main-do/
# Suppose this is foo.py.
print("before import")
import math
print("before functionA")
def functionA():
print("Function A")
print("before functionB")
def functionB():
print("Function B {}".format(math.sqrt(100)))
print("before __name__ guard")
if __name__ == '__main__':
functionA()
functionB()
print("after __name__ guard")

https://stackoverflow.com/questions/419163/what-does-if-name-main-do
emoji bug

$ ls
# chmod 777 / chmod 755
$ chmod +x ./dict.py
# 可执行脚本
# #!/usr/bin/python3
$ ./dict.py
# 指定解释器
$ python3 ./dict.py
#!/usr/bin/python3
# 一行 OK
# dict = {'Name': 'xgqfrms', 'Age': 18, 'Class': 'First'}
# 多行错误
dict = {
'Name': 'xgqfrms',
'Age': 18,
'Class': 'First',
'Country': 'China ',
}
# 更新 Age
dict['Age'] = 23
# 添加信息
dict['School'] = "Python 教程"
print ("dict['Age']: ", dict['Age'])
print ("dict['School']: ", dict['School'])
print ("dict['Country']: ", dict['Country'])
https://www.runoob.com/python3/python3-dictionary.html
refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
Python errors All In One的更多相关文章
- Python Errors and Exceptions
1. python中的try{}catch{} 2. raise exception 3. try...except ... else.. 4. finally块 python中的异常处理的keywo ...
- arcgis python 异常处理
import arcpy in_features = "c:/base/transport.gdb/roads" try: # Note: CopyFeatures will al ...
- arcgis python 发送邮件
import arcgisscripting, smtplib, os, sys, traceback from email.MIMEMultipart import MIMEMultipart fr ...
- caffe2--Install
Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...
- caffe2--ubuntu16.04--14.04--install
Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...
- Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean
http://www.360doc7.net/wxarticlenew/541275971.html 一.什么是源码包软件? 顾名思义,源码包就是源代码的可见的软件包,基于Linux和BSD系统的软件 ...
- linux安装python3.*,更换Python2.*
下载并解压:Python-3.5.7.tgz [root@AH-aQYWTYSJZX01 python3]# ll total 20268 -rw-r----- 1 temp01 temp01 207 ...
- Linux下编译安装源码包软件 configure ,make, make install, make test/check, make clean 假目标
http://www.360doc7.net/wxarticlenew/541275971.html 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 ...
- Python Tutorial 学习(八)--Errors and Exceptions
Python Tutorial 学习(八)--Errors and Exceptions恢复 Errors and Exceptions 错误与异常 此前,我们还没有开始着眼于错误信息.不过如果你是一 ...
随机推荐
- Ansible自动化运维工具的使用
Ansible自动化运维工具的使用 host lnventory 管理主机 ip root账号密码 ssh端口 core mod ...
- Golang拼接字符串的5种方法及其效率_Chrispink-CSDN博客_golang 字符串拼接效率 https://blog.csdn.net/m0_37422289/article/details/103362740
Different ways to concatenate two strings in Golang - GeeksforGeeks https://www.geeksforgeeks.org/di ...
- (SqlServe)关于字符串长度被截断的问题
1. 问题描述 在同步数据时常常会发现一个错误:将截断字符串或二进制数据. 2. 问题原因 这个问题出现的原因是:要插入的数值字段的长度超出了数据库中字段的长度.比如:插入的字符串字节长度是40,数据 ...
- 向同一个模型的外键反向关联名称产生了冲突 Django迁移
向同一个模型的外键反向关联名称产生了冲突 一个模型中有两个外键指向同一张表时,创建迁移模型时报错:" HINT: Add or change a related_name argument ...
- 20201104gryz模拟赛解题报告
写在前面 \(Luckyblock\) 良心出题人, 题面好评 T1还是蛮简单的,用一个栈来维护就能过(某天听说 \(Luckyblock\) 出了套题,T1是个考栈的,看来就是这道了 注:栈的清空只 ...
- power network 电网——POJ1459
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 27282 Accepted: 14179 D ...
- Jenkins (自动使用docker容器发布java.war +tomcat)
一.大概流程 因为目前没有找Jenkins 和docker 之间比较友好的插件,所以只能使用这种比较low 的方式来实现自动部署了. 1.Jenkins在gitlab拉取项目并编译. 2.将编译后的代 ...
- linux shell判断文件,目录是否存在或者具有权限
在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结: #!/bin/sh myPath="/var/log/httpd/" myFi ...
- size_t 、wchar_t和 ptrdiff_t
size_t在C语言中就有了. 它是一种"整型"类型,里面保存的是一个整数,就像int, long那样.这种整数用来记录一个大小(size).size_t的全称应该是size ty ...
- CCF-命令行选项(模拟)
命令行选项 问题描述 请你写一个命令行分析程序,用以分析给定的命令行里包含哪些选项.每个命令行由若干个字符串组成,它们之间恰好由一个空格分隔.这些字符串中的第一个为该命令行工具的名字,由小写字母组 ...