Python Tool Visual Studio简单使用
由于一直在做.NET的开发,一直用的IDE是VS系列的,所以想用VS也能开发Python,刚好微软提供一个插件PTVS(Python Tool Visual Studio)专门应用于Python开发的,但是很可惜没有提供中文版本的,只有英文版本的,对于英语很差的我来说是一种考验呀!!!!!!!!!!!
Sort与Sorted
无意中用PTVS插件做列表的排序的时候发现,用Python自己带的SCMD命令Sort或者Sorted排序都行,但是在插件中Sort就不行
貌似必须使用Sorted使用才行,这真是百思不得。
s=[1,2,3,4,15,1,1] print(sorted(s))
格式化日期的使用
使用 time 模块的 strftime 方法来格式化日期
import time
# 格式化成2016-03-20 11:45:39形式
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
# 格式化成Sat Mar 28 22:24:24 2016形式
print time.strftime("%a %b %d %H:%M:%S %Y", time.localtime())
# 将格式字符串转换为时间戳
a = "Sat Mar 28 22:24:24 2016"
print time.mktime(time.strptime(a,"%a %b %d %H:%M:%S %Y"))
获取日历
import calendar cal=calendar.month(2016,7) print(cal)
对IO的一些操作
读取文件
>>>f=open("G:\\Python\\txt1.txt","r")
>>>f.read()
读出内容
>>>f.close()
写入文件内容
>>>f=open("G:\\Python\\txt1.txt","w")
>>>f.write("Python") #写入内容
>>>f.close()
自定义函数的写法,这里面多注意冒号:的写法,还有就是空格的使用,不然很容易报错的
>>>def my_function(x): ... if x>=0: ... return x ... else: ... return -x ... >>> my_function(5) 5
>>>def my_print():
... print("i am is python")
... return
...
>>> my_print()
i am is python
匿名函数的写法
关键字lambda表示匿名函数,冒号前面的x表示函数参数。
匿名函数有个限制,就是只能有一个表达式,不用写return,返回值就是该表达式的结果。
>>>f=lambda x:x+x >>>f(5) 10
Python Tool Visual Studio简单使用的更多相关文章
- [转]Python in Visual Studio Code
本文转自:https://code.visualstudio.com/docs/languages/python Working with Python in Visual Studio Code, ...
- Visual Studio 简单使用常识操作
Visual Studio 简单使用个人总结 转载请注明来源:www.cnblogs.com/icmzn(后续会持续更新) 可以查看一下链接,官方关于visual studio 2010 的介绍 ...
- Python + Djang+ Visual Studio Code(VSCode)
使用 Visual Studio Code(VSCode)搭建简单的 Python + Django 开发环境 https://www.cnblogs.com/Dy1an/p/10130518.htm ...
- Python 在Visual studio 中做单元测试进行TDD开发
Unit Tests Steve Dower edited this page on 14 Jul · 3 revisions Pages 38 Home Azure Remote Debugging ...
- 在 C 代码中嵌入 Python 语句或使用 Python 模块 (Visual Studio 2013 环境设置)
1) 新建一个 内嵌 Python 语句的 C 代码, // This is a test for check insert the Python statements or module in C. ...
- 【Python】Visual Studio Code 安装&&使用 hello python~~~~
1.安装Python 官网下载: https://www.python.org/downloads/ 选择版本下载 2.下载完毕后,点击安装. 3.看到页面,直接下一步,全部默认选项. 4.安装即 ...
- [tool] Visual Studio Code python配置
语言设置 安装中文插件即可成为中文 选择一个Python解释器 Python是一种解释型语言,为了运行Python代码并获取Python IntelliSense,您必须告诉VS Code使用哪个解释 ...
- [Tool] Visual Studio必备插件 + 技能
总结自己常用的VS插件,其中部分需要注册. 在该链接http://www.cnblogs.com/neverc/p/4591501.html中提供 1.Web Essentials(测试支持2010, ...
- python c++ Visual Studio相关 Unable to find vcvarsall.bat问题
使用Cython编译包的时候报错: Unable to find vcvarsall.bat 说明:https://jingyan.baidu.com/article/adc815138162e8f7 ...
随机推荐
- Apache-系统-网络部分配置
参考了很多东西,但有些理解可能会有错误的地方,希望看到错误的地方可以即使纠正. 参考的内容. http://netsecurity.51cto.com/art/200608/30428.htm htt ...
- CloudStack的VO在调用setRemoved方法抛异常的原因
今天在开发中发现一个问题,本来想对一个VO对象的removed值赋值,然后去update一下这条记录,一个最简单的set方法,但是在调用时直接抛异常了. 1: public void setRemov ...
- Nmap 源代码学习四 软件简单使用
软件安装环境是win7.使用Zenmap, nmap6.49BETA2 扫描主机port nmap -T4 -A -v 192.168.0.207 输出结果: 扫描整个子网 nmap 192.168. ...
- workflow 工作流
https://documentation.devexpress.com/#Xaf/CustomDocument3356
- Citrix 服务器虚拟化之二十七 XenApp6.5发布服务器桌面
Citrix 服务器虚拟化之二十七 XenApp6.5发布服务器桌面 XenApp可发布以下类型的资源向用户提供信息访问,这些资源可在服务器或桌面上虚拟化: 1) 服务器桌面:发布场中服务器的整个 ...
- [Angular2 Form] Style Validation in Angular 2 Forms
Inputs using Angular 2’s ngModel automatically apply style classes of .ng-validand .ng-invalid each ...
- IOS编程User Interface基础
IOS编程之User Interface基础 目录 概述 相关概念 常见问题 状态栏的隐藏 应用图标的设置 概述 IOS用户界面是APP呈现给用户最直观.最常用的方式,因此学会用户界面的编程是学习IO ...
- careercup-高等难度 18.2
18.2 编写一个方法,洗一副牌.要求做到完美洗牌,换言之,这幅牌52!种排列组合出现的概率相同.假设给定一个完美的随机发生器. 解法:假定有个数组,含有n个元素,类似如下: [1][2][3][4] ...
- 进程控制之fork函数
一个现有进程可以调用fork函数创建一个新进程. #include <unistd.h> pid_t fork( void ); 返回值:子进程中返回0,父进程中返回子进程ID,出错返回- ...
- debian7 编译qtopia错误解决案例
问题: kernel/qjpegio.cpp:60:21: error: jpeglib.h: No such file or directory 解决 sudo apt-get install li ...