程序设计

专业和发烧友程序员的问答

12
在virtualenv中升级python
有没有一种方法可以升级virtualenv中使用的python版本(例如,如果出现错误修复版本)? 我可以pip freeze --local > requirements.txt删除目录和pip install -r requirements.txt,但这需要大量重新安装大型库,例如,numpy我经常使用。 我可以看到从2.6-> 2.7升级时这是一个优势,但是2.7.x-> 2.7.y呢?



8
将元组转换为列表并返回
我目前正在使用平铺地图为pygame中的游戏开发地图编辑器。该级别由以下结构的块构成(尽管更大): level1 = ( (1,1,1,1,1,1) (1,0,0,0,0,1) (1,0,0,0,0,1) (1,0,0,0,0,1) (1,0,0,0,0,1) (1,1,1,1,1,1)) 其中“ 1”是一堵墙,而“ 0”是一堵空楼。 以下代码基本上是处理块类型更改的代码: clicked = pygame.mouse.get_pressed() if clicked[0] == 1: currLevel[((mousey+cameraY)/60)][((mousex+cameraX)/60)] = 1 但是由于级别存储在元组中,因此我无法更改不同块的值。如何轻松更改级别中的不同值?
206 python  list  tuples 

7
使用Bash时需要转义哪些字符?
在Bash中是否有需要转义的字符的完整列表?可以仅通过进行检查sed吗? 特别是,我正在检查是否%需要逃脱。我试过了 echo "h%h" | sed 's/%/i/g' 并且工作得很好,没有逃脱%。这是否意味着%不需要逃脱?这是检查必要性的好方法吗? 更笼统:它们是shell和一起逃脱的相同字符bash吗?

10
如何获取RxJS Subject或Observable的当前值?
我有一个Angular 2服务: import {Storage} from './storage'; import {Injectable} from 'angular2/core'; import {Subject} from 'rxjs/Subject'; @Injectable() export class SessionStorage extends Storage { private _isLoggedInSource = new Subject<boolean>(); isLoggedIn = this._isLoggedInSource.asObservable(); constructor() { super('session'); } setIsLoggedIn(value: boolean) { this.setItem('_isLoggedIn', value, () => { this._isLoggedInSource.next(value); }); } } 一切正常。但是我还有另一个不需要订阅的组件,它只需要在某个时间点获取isLoggedIn的当前值即可。我怎样才能做到这一点?
206 javascript  angular  rxjs 

7
对Docker -t选项分配伪TTY感到困惑
此选项的作用是什么?我已经阅读了很多有关TTY的文章,但仍然感到困惑。我试过没有-t和正义-i,似乎期望用户输入的程序如果没有则抛出错误-t。启用伪TTY为何很重要?
206 docker  tty  pty 

14
ImportError:没有名为“ Tkinter”的模块
由于某些原因,我无法使用Tkinteror tkinter模块。在python shell中运行以下命令后 import Tkinter 要么 import tkinter 我得到这个错误 ModuleNotFoundError:没有名为“ Tkinter”的模块 要么 ModuleNotFoundError:没有名为“ tkinter”的模块 可能是什么原因,我们如何解决呢?
206 python  tkinter 


25
尝试推送时出现Git错误-预接收钩被拒绝
当我尝试推送已提交的更改时,出现以下错误... git.exe push -v --progress "origin" iteration1:iteration1 remote: ********************************************************************* To ssh://git@mycogit/cit_pplus.git ! [remote rejected] iteration1 -> iteration1 (pre-receive hook declined) error: failed to push some refs to 'ssh://git@mycogit/cit_pplus.git' 这是怎么回事?
206 git 

12
如何从命令行运行TypeScript文件?
我很难找到答案。使用普通的Node.JS,您可以运行带有node path/to/file.js,CoffeeScript coffee hello.coffee和ES6都具有的任何js文件babel-node hello.js。我该如何处理Typescript? 我的项目有一个tsconfig.json供Webpack / ts-loader使用的工具,用于为浏览器构建一个不错的小捆绑包。不过,在此之前,我需要从控制台运行一个构建步骤,该步骤将使用.ts项目中使用的一些文件来生成模式,但是我似乎无法在不编译的情况下运行单个Typescript文件整个项目。

25
NPM安装错误:解析“…nt-webpack-plugin”:“ 0”附近时,JSON输入意外结束
创建新的Angular 5项目时: 节点版本:8.9.2 npm版本:5.5.1 我的命令是 npm install -g @angular/cli 错误是 npm ERR! **Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'** npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Aashitec\AppData\Roaming\npm-cache\_logs\2017-12-06T13_10_10_729Z-debug.log 错误日志为http://www.aashitechno.in/2017-12-06T13_10_10_729Z-debug.log

6
通过Angular中的路由路径发送数据
无论如何,使用router.navigate将数据作为参数发送?我的意思是,就像这个示例一样,您可以看到路线具有data参数,但是这样做是行不通的: this.router.navigate(["heroes"], {some-data: "othrData"}) 因为some-data不是有效的参数。我怎样才能做到这一点?我不想使用queryParams发送参数。


14
请求失败:不可接受的内容类型:使用AFNetworking 2.0的text / html
我正在试用新版本的AFNetworking 2.0,但遇到了以上错误。知道为什么会这样吗?这是我的代码: NSURL *URL = [NSURL URLWithString:kJSONlink]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request]; op.responseSerializer = [AFJSONResponseSerializer serializer]; [op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; [[NSOperationQueue mainQueue] addOperation:op]; 我正在使用Xcode 5.0。 另外,这是错误消息: Error: Error Domain=AFNetworkingErrorDomain …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.