python, my first code

# coding:utf-8

from random import randint

num=randint(1,100)

print "guess the right number ,so please input a number:"

a=1

while a==1:

answer=input() ##把输入赋值给answer以便条件中用到比较大小

if answer<num :

print "it‘s too small"

if answer>num :

print "it‘s too big"

if answer==num :

print "right"

时间: 2024-12-17 16:32:59

python, my first code的相关文章

Java vs. Python (1): Simple Code Examples

Some developers have claimed that Python is more productive than Java. It is dangerous to make such a claim, because it may take several days to prove that thoroughly. From a high level view, Java is statically typed, which means all variable names h

python linecache source code

The source code of linecache.py from python 2.0 is here. from stat import * Get file information >>> filestat = os.stat('README.TXT') >>> filestat nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size

python单线程爬虫code

广度优先算法: # -*- coding: utf-8 -*- import urllib import urllib.request from bs4 import BeautifulSoup import threading mylock = threading.RLock() class Crawler: unVisitUrl = set() visitedUrl = [] def getHtml(self , url): html = '' req = urllib.request.Re

python参数Sample Code

import time import datetime import getopt import sys try: opts, args = getopt.getopt(sys.argv[1:], "ho:", ["inputOCR=", "inputSpeech="]) except getopt.GetoptError: print ('Getopt Error!') sys.exit(1) for name, value in opts:

Exploring Python Code Objects

Exploring Python Code Objects https://late.am/post/2012/03/26/exploring-python-code-objects.html Inspired by David Beazley's Keynote at PyCon, I've been digging around in code objects in Python lately. I don't have a particular axe to grind, nor some

Python 自动刷博客浏览量

哈哈,今天的话题有点那什么了哈.咱们应该秉承学习技术的角度来看,那么就开始今天的话题吧. 思路来源 今天很偶然的一个机会,听到别人在谈论现在的"刷量"行为,于是就激发了我的好奇心.然后看了下requests模块正好对我有用,就写了一个简单的测试用例.神奇的发现这一招竟然是管用的.那还等什么,开刷咯. 前奏 思路很简单,就是一个发送请求的实现,就可以了.代码如下: headers = { 'referer':'http://blog.csdn.net/', 'User-Agent':'M

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

Machine and Deep Learning with Python

Machine and Deep Learning with Python Education Tutorials and courses Supervised learning superstitions cheat sheet Introduction to Deep Learning with Python How to implement a neural network How to build and run your first deep learning network Neur