技术标签: python getchar功能
本文整理汇总了Python中msvcrt.getwch方法的典型用法代码示例。如果您正苦于以下问题:Python msvcrt.getwch方法的具体用法?Python msvcrt.getwch怎么用?Python msvcrt.getwch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块msvcrt的用法示例。
在下文中一共展示了msvcrt.getwch方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getkey
点赞 6
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def getkey(self):
while True:
z = msvcrt.getwch()
if z == unichr(13):
return unichr(10)
elif z is unichr(0) or z is unichr(0xE0):
try:
code = msvcrt.getwch()
if z is unichr(0):
return self.fncodes[code]
else:
return self.navcodes[code]
except KeyError:
pass
else:
return z
开发者ID:wendlers,项目名称:mpfshell,代码行数:18,
示例2: getkey
点赞 6
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def getkey(self) -> str:
while True:
z = msvcrt.getwch()
if z == chr(13):
return chr(10)
elif z is chr(0) or z is chr(0xe0):
try:
code = msvcrt.getwch()
if z is chr(0):
return self.fncodes[code]
else:
return self.navcodes[code]
except KeyError:
pass
else:
return z
开发者ID:vlasovskikh,项目名称:intellij-micropython,代码行数:18,
示例3: win_getpass
点赞 6
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def win_getpass(prompt='Password: ', stream=None):
"""Prompt for password with echo off, using Windows getch()."""
if sys.stdin is not sys.__stdin__:
return fallback_getpass(prompt, stream)
for c in prompt:
msvcrt.putwch(c)
pw = ""
while 1:
c = msvcrt.getwch()
if c == '\r' or c == '\n':
break
if c == '\003':
raise KeyboardInterrupt
if c == '\b':
pw = pw[:-1]
else:
pw = pw + c
msvcrt.putwch('\r')
msvcrt.putwch('\n')
return pw
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,
示例4: win_getpass
点赞 6
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def win_getpass(prompt='Password: ', stream=None):
"""Prompt for password with echo off, using Windows getch()."""
if sys.stdin is not sys.__stdin__:
return fallback_getpass(prompt, stream)
import msvcrt
for c in prompt:
msvcrt.putwch(c)
pw = ""
while 1:
c = msvcrt.getwch()
if c == '\r' or c == '\n':
break
if c == '\003':
raise KeyboardInterrupt
if c == '\b':
pw = pw[:-1]
else:
pw = pw + c
msvcrt.putwch('\r')
msvcrt.putwch('\n')
return pw
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:23,
示例5: __ichr
点赞 6
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def __ichr(self):
addr = self.__stck.pop()
# Input Routine
while msvcrt.kbhit():
msvcrt.getwch()
while True:
char = msvcrt.getwch()
if char in '\x00\xE0':
msvcrt.getwch()
elif char in string.printable:
char = char.replace('\r', '\n')
msvcrt.putwch(char)
break
item = ord(char)
# Storing Number
self.__heap.set_(addr, item)
开发者ID:ActiveState,项目名称:code,代码行数:18,
示例6: cancel
点赞 5
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def cancel(self):
# CancelIo, CancelSynchronousIo do not seem to work when using
# getwch, so instead, send a key to the window with the console
hwnd = ctypes.windll.kernel32.GetConsoleWindow()
ctypes.windll.user32.PostMessageA(hwnd, 0x100, 0x0D, 0)
开发者ID:wendlers,项目名称:mpfshell,代码行数:7,
示例7: getkey
点赞 5
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def getkey(self):
while True:
z = msvcrt.getwch()
if z == unichr(13):
return unichr(10)
elif z in (unichr(0), unichr(0x0e)): # functions keys, ignore
msvcrt.getwch()
else:
return z
开发者ID:cedricp,项目名称:ddt4all,代码行数:11,
示例8: cancel
点赞 5
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def cancel(self):
# CancelIo, CancelSynchronousIo do not seem to work when using
# getwch, so instead, send a key to the window with the console
hwnd = ctypes.windll.kernel32.GetConsoleWindow()
ctypes.windll.user32.PostMessageA(hwnd, 0x100, 0x0d, 0)
开发者ID:cedricp,项目名称:ddt4all,代码行数:7,
示例9: getkey
点赞 5
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def getkey(self):
while True:
z = msvcrt.getwch()
if z == chr(13):
return chr(10)
elif z in (chr(0), chr(0x0e)): # functions keys, ignore
msvcrt.getwch()
else:
return z
开发者ID:purduesigbots,项目名称:pros-cli2,代码行数:11,
示例10: get_key
点赞 5
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def get_key():
ch = msvcrt.getwch()
if ch in ('\x00', '\xe0'): # arrow or function key prefix?
ch = msvcrt.getwch() # second call returns the actual key code
if ch in const.KEY_MAPPING:
return const.KEY_MAPPING[ch]
if ch == 'H':
return const.KEY_UP
if ch == 'P':
return const.KEY_DOWN
return ch
开发者ID:nvbn,项目名称:thefuck,代码行数:15,
示例11: __iint
点赞 5
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def __iint(self):
addr = self.__stck.pop()
# Input Routine
while msvcrt.kbhit():
msvcrt.getwch()
buff = ''
char = msvcrt.getwch()
while char != '\r' or not buff or len(buff) == 1 and buff in '+-':
if char in '\x00\xE0':
msvcrt.getwch()
elif char in '+-' and not buff:
msvcrt.putwch(char)
buff += char
elif '0' <= char <= '9':
msvcrt.putwch(char)
buff += char
elif char == '\b':
if buff:
buff = buff[:-1]
msvcrt.putwch(char)
msvcrt.putwch(' ')
msvcrt.putwch(char)
char = msvcrt.getwch()
msvcrt.putwch(char)
msvcrt.putwch('\n')
item = int(buff)
# Storing Number
self.__heap.set_(addr, item)
开发者ID:ActiveState,项目名称:code,代码行数:30,
示例12: getchar
点赞 4
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def getchar(echo):
# The function `getch` will return a bytes object corresponding to
# the pressed character. Since Windows 10 build 1803, it will also
# return \x00 when called a second time after pressing a regular key.
#
# `getwch` does not share this probably-bugged behavior. Moreover, it
# returns a Unicode object by default, which is what we want.
#
# Either of these functions will return \x00 or \xe0 to indicate
# a special key, and you need to call the same function again to get
# the "rest" of the code. The fun part is that \u00e0 is
# "latin small letter a with grave", so if you type that on a French
# keyboard, you _also_ get a \xe0.
# E.g., consider the Up arrow. This returns \xe0 and then \x48. The
# resulting Unicode string reads as "a with grave" + "capital H".
# This is indistinguishable from when the user actually types
# "a with grave" and then "capital H".
#
# When \xe0 is returned, we assume it's part of a special-key sequence
# and call `getwch` again, but that means that when the user types
# the \u00e0 character, `getchar` doesn't return until a second
# character is typed.
# The alternative is returning immediately, but that would mess up
# cross-platform handling of arrow keys and others that start with
# \xe0. Another option is using `getch`, but then we can't reliably
# read non-ASCII characters, because return values of `getch` are
# limited to the current 8-bit codepage.
#
# Anyway, Click doesn't claim to do this Right(tm), and using `getwch`
# is doing the right thing in more situations than with `getch`.
if echo:
func = msvcrt.getwche
else:
func = msvcrt.getwch
rv = func()
if rv in (u'\x00', u'\xe0'):
# \x00 and \xe0 are control characters that indicate special key,
# see above.
rv += func()
_translate_ch_to_exc(rv)
return rv
开发者ID:Frank-qlu,项目名称:recruit,代码行数:44,
示例13: inkey
点赞 4
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def inkey(self, timeout=None):
# Since get_key is a single method, we will just do the cbreak
# and input stuff in a single method.
# We should ever need inkey without cbreak
if sys.version_info[0] >= 3:
from msvcrt import kbhit, getwch as _getch
else:
from msvcrt import kbhit, getch as _getch
def readInput():
start_time = time.time()
while True:
if kbhit():
return _getch()
if (time.time() - start_time) > timeout:
return None
key = readInput()
if not key:
return None
if key == '\x03':
# Ctrl C
raise CaughtSignal(2, None)
elif key == '\x1c':
# Ctrl \
sys.exit(1)
elif key == '\xe0':
# Its an arrow key, get next symbol
next_key = _getch()
if next_key == 'H':
return Val(name='KEY_UP', code=259)
elif next_key == 'K':
return Val(name='KEY_LEFT', code=260)
elif next_key == 'P':
return Val(name='KEY_DOWN', code=258)
elif next_key == 'M':
return Val(name='KEY_RIGHT', code=261)
elif key == '\x1b':
return Val(name='KEY_ESCAPE', code=361)
elif key == '\x0d':
return Val(name='KEY_ENTER', code=362)
else:
return Val(key=key)
开发者ID:QData,项目名称:deepWordBug,代码行数:51,
示例14: getchar
点赞 4
# 需要导入模块: import msvcrt [as 别名]
# 或者: from msvcrt import getwch [as 别名]
def getchar(echo):
# The function `getch` will return a bytes object corresponding to
# the pressed character. Since Windows 10 build 1803, it will also
# return \x00 when called a second time after pressing a regular key.
#
# `getwch` does not share this probably-bugged behavior. Moreover, it
# returns a Unicode object by default, which is what we want.
#
# Either of these functions will return \x00 or \xe0 to indicate
# a special key, and you need to call the same function again to get
# the "rest" of the code. The fun part is that \u00e0 is
# "latin small letter a with grave", so if you type that on a French
# keyboard, you _also_ get a \xe0.
# E.g., consider the Up arrow. This returns \xe0 and then \x48. The
# resulting Unicode string reads as "a with grave" + "capital H".
# This is indistinguishable from when the user actually types
# "a with grave" and then "capital H".
#
# When \xe0 is returned, we assume it's part of a special-key sequence
# and call `getwch` again, but that means that when the user types
# the \u00e0 character, `getchar` doesn't return until a second
# character is typed.
# The alternative is returning immediately, but that would mess up
# cross-platform handling of arrow keys and others that start with
# \xe0. Another option is using `getch`, but then we can't reliably
# read non-ASCII characters, because return values of `getch` are
# limited to the current 8-bit codepage.
#
# Anyway, Click doesn't claim to do this Right(tm), and using `getwch`
# is doing the right thing in more situations than with `getch`.
if echo:
func = msvcrt.getwche
else:
func = msvcrt.getwch
rv = func()
if rv in (u"\x00", u"\xe0"):
# \x00 and \xe0 are control characters that indicate special key,
# see above.
rv += func()
_translate_ch_to_exc(rv)
return rv
开发者ID:pypa,项目名称:pipenv,代码行数:44,
注:本文中的msvcrt.getwch方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。
硬链接:ln 源文件 目标文件。通过索引节点inode来进行链接,一个文件会有一个编号,这个编号就是inode多个文件指向同一个inode就称为硬链接。作用:允许一个文件拥有多个有效路径(多个入口),这样用户就可以建立硬链接到重要的文件,以防止“误删”源数据。ext2文件系统中,一个inode含有多个文件,删除一个文件并不影响其他文件。最后一个文件被删除时,释放inode。1) 硬链接文件是具有相同inode节点号的不同文件2) 删除硬链接文件或者删除源文件之一,文件实体并未被删除3) 只有删除
递归与分治法实现快速排序算法,输入一串以英文字符逗号隔开的数字,按升序排列法实现快速排序算法。主要是要了解明白递归快速排序,然后进行代码的缝合编写。请耐心!!!
由于实验室机房处于内网环境,无法与外网交互,导致无法使用yum命令在线下载配置环境。因此,我在Windows环境(可连接外网)下使用Xftp6来进行个人PC机与机房服务器进行交互管理,在Windows环境中下载rpm安装包通过Xftp上传到机房Linux服务器中,然后离线安装Docker以及docker-compose安装环境:CentOS:release 7.9.2009(Server with GUI)Docker:19.03.13Docker-compose:1.27.4下载离线安
综合教材等资源以及个人经验,整理出超全面的verilog实战,包含基本语法搭配小项目练习和分析、进阶语法和进阶项目分析、常见的综合项目分析和实践
RGBToLab/ReadMe.txtRGBToLab/res/RGBToLab.icoRGBToLab/res/RGBToLab.rc2RGBToLab/Resource.hRGBToLab/RGBToLab.apsRGBToLab/RGBToLab.clwRGBToLab/RGBToLab.cppRGBToLab/RGBToLab.dspRGBToLab/RGBToLab.dswRGBToLa...
文章目录1.局域网和广域网2. 网络分层2.1 网络为什么要分层?2.2 OSI分层模型与TCP/IP分层模型的区别 3. 局域网的通信原理3.1 交换机4. 数据包的封装与分用5. MAC地址和IP地址的区别1.局域网和广域网 早期 生产计算机 的目的就是为了 计算,但每个计算机之间相互独立。小A可以在计算机A上完成计算,小B可以在计算机B上完成计算,小C可以在计算机C上完成计算,但是三...
分治算法(递归)一、基本概念二、基本思想及策略三、分治法适用的情况四、分治法的基本步骤五、分治法的复杂性分析六、可使用分治法求解的一些经典问题七、依据分治法设计程序时的思维过程一、基本概念在计算机科学中,分治法是一种很重要的算法。字面上的解释是“分而治之”,就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题……直到最后子问题可以简单的直接求解,原问题的解即子问题的解的合并。这个技巧是很多高效算法的基础,如排序算法(快速排序,归并排序),傅立叶变换(快速傅立叶变换)……任
首先需要安装ftp服务程序[email protected]:~ $ sudo apt-get [email protected]:~ $ sudo apt-get install vsftpd安装成功后,ftp就已经可以登录和浏览文件了,但是不能写,需要更改写权限。树莓派raspbian系统默认登录用户是pi,默认密码是 raspberry , 更改写权限,要对ftp进行配置
背景最近做了一个需求,要再手机页面上播放背景音乐,看起来简单,其实不然。安卓可以自动播放但ios却不可以。H5的出现对多媒体在网页上的视频播放提供很好的支持,以前网页播放视频基本依赖于flash等插件。而H5的video标签实现了网页播放视频无插件化。当前,绝大多数浏览器都支持H5的video标签,除了部分PC端浏览器比如IE还不支持。Android上在 video标签上添加autopla...
普通用户访问hadoop文件管理系统如果分布式文件系统的安装用户是root的话,那么,对于一个普通用户来说,是不能对hdfs的文件目录进行读写操作。linux操作系统:cent OS 6普通用户使用命令hadoop fs -mkdir /normal这样的命令就会报错:permisson denined user='yourusername',access= xxxx,inode =...
题目: 两个数码管,K1,K2两个按键,完成K1启动计数,K2暂停计数,每一秒钟数码管增加1,60秒钟后,蜂鸣器响一声,数码管回归0,重新计数。代码 #include"reg51.h" #include"intrins.h" #define seg1 P0 #define seg2 P2 typedef unsigned int u16; typedef unsigned char ...
目前Spring官方还没有出整合Mybatis的特性,但是mybitis比较给力,开发了一个mybatis-spring插件,达到与Spring的完美整合目的。 在与Spring集成前,一方面我们需要下载Spring的所需的jar文件,我是刚才Spring官方网站上下载的最新的spring-framework-3.2.2.RELEASE-dist.zip压缩文件,里面包含了