python-modules

python模块的使用

 1 #! /usr/bin/env pyton3.5.4
 2 # -*- conding="utf-8" -*-
 3
 4 # 使用sys模块
 5 from sys import *
 6
 7
 8 for i in argv:
 9     print(i)
10
11     print(‘\n\nthe PythonPath is‘, path, ‘\n‘)
12
13
14 # 模块的__name__:每个模块都有name。当name是main时,可单独运行:
15 # 假如我们只想在程序本身被使用的时候运行主块,而在它被别的模块输入的时候不运行主块--可以通过模块的__name__属性完成
16 ‘‘‘
17 __name__ = ‘__kobe__‘
18
19 if __name__ == ‘__main__‘:
20     print(‘itself‘)
21 else:
22     print(‘kobe‘)
23 ‘‘‘
24
25 # __doc__的使用
26 ‘‘‘
27 def print_max(x, y):
28     ‘
29     The maximum of two numbers,
30
31     the larger one.
32     ‘
33     x = int(x)
34     y = int(y)
35     if x > y:
36         print(‘max is:‘, x)
37     else:
38         print(‘max is:‘, y)
39
40
41 print_max(3, 6)
42 help(print_max)
43 print(print_max.__doc__)
44 ‘‘‘

    

时间: 2024-12-21 10:14:31

python-modules的相关文章

解决yum升级的问题“There was a problem importing one of the Python modules”

yum命令升级的时候,报出这个错误. There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named yum Please install a package which provides this module, or verify that the module is installed cor

Python Modules and Packages – An Introduction

This article explores Python modules and Python packages, two mechanisms that facilitate modular programming. Modular programming refers to the process of breaking a large, unwieldy programming task into separate, smaller, more manageable subtasks or

[Python] Reuse Code in Multiple Projects with Python Modules

A module is a function extracted to a file. This allows you to import the function and use it in any other code you may write. You’ll learn how to create modules, import them, and make them stand-alone as you learn what if __name__ == “__main__” mean

Install Python Modules

1. using pip (for ubuntu: using "sudo apt-get install python3-pip" to install pip for python3): pip install mudulename 2. using sudo command in Linux in condition that pip doesn't work, for example the Tkinter module: sudo apt-get install python

[Python Modules] unittest.mock

五夜光寒,照来积雪平于栈.西风何限,自起披衣看. 对此茫茫,不觉成长叹.何时旦,晓星欲散,飞起平沙雁. 在某个Python程序中看到这么一行 from unittest import mock 看起来像是一个Python自带的测试库.经查,unittest.mock允许用户使用假的对象代替系统的真实对象.mock库中常用的是MagicMock, Mock, patch(): >>> from unittest.mock import MagicMock >>> thin

python升级安装后的yum的修复

升级python版本号后,执行yum # yum -y install openssl 提演示样例如以下: There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named yum Please install a package which provides this module, or veri

Python升级版本及版本升级后Yum无法使用的解决方法

#升级版本 yum -y install gcc cd /opt wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz tar xf Python-2.7.6.tgz  ./configure --prefix=/usr/local/python2.7  cd Python-2.7.6 ./configure --prefix=/usr/local/python2.7  make && make install mv /usr/b

CentOS7 升级python同时解决yum损坏问题

CentOS7中的python版本为python2.7.5,升级到最新版的python时需要注意两个问题 新版的python安装好后要修改python的系统默认指向问题 升级到最新版python后yum报错的问题 下面对新版的安装步骤进行说明. 一.下载并安装最新版python 1.下载并解压 # wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz # tar -zxf Python-3.5.2.tgz 2.安装Python

Python著名的lib和开发框架(均为转载)

第一,https://github.com/vinta/awesome-python Awesome Python A curated list of awesome Python frameworks, libraries, software and resources. Inspired by awesome-php. Awesome Python Admin Panels Algorithms and Design Patterns Anti-spam Asset Management A

Python框架、库以及软件资源汇总

转自:http://developer.51cto.com/art/201507/483510.htm 很多来自世界各地的程序员不求回报的写代码为别人造轮子.贡献代码.开发框架.开放源代码使得分散在世界各地的程序员们都能够贡献他们的代码与创新. Python就是这样一门受到全世界各地开源社区支持的语言.Python可以用来开发各种小工具软件.web应用.科学计算.数据分析等等,Python拥有大量的流行框架,比如Django.使用Python框架时,可以根据自己的需求插入不同的模块,比如可以用S