Study Environment
Python 3.6 + Eclipse neon.3 4.6.3
#......................................................................分界线..................................................................................................
#基本上所有的程序开发,学习第一个输入都是这个,大家应该都知道。
print("Hello World!")
结果:
Hello World!
#............................................................................分界线.....................................................................................................
# 打印当前计算机名及内网地址
import socket
import datetime
myname = socket.getfqdn(socket.gethostname())
myaddr = socket.gethostbyname(myname)
today = datetime.date.today()
print (myname)
print (myaddr)
print(today) #打印当天的日期
结果:
AAA.domain01.net
192.168.0.132
2017-9-4
#......................................................................分界线.........................................................................................................
#password 不可见
import getpass
_username = ‘Ben‘
_password = 123
username = input("username:")
password = getpass.getpass("password:")
if _username == username and _password == password:
print("Welcome user {name} login..".format(name=username))
else:
print("Invalid username or password !")
#........................................................................................分界线.............................................................................................................
#如何查询数据类型
print(type("变量"))
eg:
name = input("Name:")
age = input("Age:")
print(type("Age:")
Job = input("Job:")
结果:
Name: Ben
Age:23
<Class ‘Str‘> # 这里提示Age输入的类型为字符型
Job: IT
总结:
在这个环境上面,唯一不太好用的,有些库没有,要自己找安装包进行处理。
建议使用Anaconda2-4.4.0-Windows-x86_64-Python3.6 + pycharm-professional-2017.1.4-Win开发工具。