如果我有一个非AMD模块命名old.js并在此脚本中我有两个功能f1并已f2定义.我需要使用它们,我如何导出它们?
require.config({
paths: {
"jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min",
},
shim: {
"old": {
deps: ["jquery"],
exports: ["f1", "f2"]
}
},
urlArgs: "bust=" + (new Date()).getTime()
});
Run Code Online (Sandbox Code Playgroud)
这不行.我会得到split错误.doc没有提到多个(http://requirejs.org/docs/api.html#config-shim)我认为这是因为即使那些jquery示例都是单独的文件,它们也有"入口"函数/类.
来自Javascript:The Definitive Guide,
var o = { x:1 }; // Start with an object
o.x = 2; // Mutate it by changing the value of a property
o.y = 3; // Mutate it again by adding a new property
Run Code Online (Sandbox Code Playgroud)
{x:1}在这做什么?使用大括号,它会让我想起函数(或对象,构造函数).有人可以详细说明,谢谢.
另一个相关问题是:
({x:1, y:2}).toString() // => "[object Object]"
Run Code Online (Sandbox Code Playgroud)
我发现这个问题也很有趣.上面代码中对象和对象有什么区别?事实上,我们什么时候使用Object?
(gdb) disas /m main
Dump of assembler code for function main():
2 {
0x080483f4 <+0>: push %ebp
0x080483f5 <+1>: mov %esp,%ebp
0x080483f7 <+3>: sub $0x10,%esp
3 int a = 1;
0x080483fa <+6>: movl $0x1,-0x4(%ebp)
4 int b = 10;
0x08048401 <+13>: movl $0xa,-0x8(%ebp)
5 int c;
6 c = a + b;
0x08048408 <+20>: mov -0x8(%ebp),%eax
0x0804840b <+23>: mov -0x4(%ebp),%edx
0x0804840e <+26>: lea (%edx,%eax,1),%eax
0x08048411 <+29>: mov %eax,-0xc(%ebp)
7 return 0;
0x08048414 <+32>: mov $0x0,%eax
8 }
0x08048419 <+37>: leave …Run Code Online (Sandbox Code Playgroud) 举个例子:
// myheader.h
static int myStaticVar = 0;
// If we remove 'static' the compiler will throw linker error.
void DoStuff();
// and myheader.cpp, and main.cpp; etc
Run Code Online (Sandbox Code Playgroud)
这就是我解释它的方式:
静态变量没有外部链接,当我们编译没有'static'时,我们在每个文件中"包含"静态变量(这里是全局的),这会创建重复项,并且链接器将抛出错误,因为不允许多次声明.
有没有更好的方法来解释这个?谢谢.
PS:我们假设在头文件中有静态变量(不是在谈论成员)吗?
请帮帮我.我在Fedora 16上这样做.
我的虚拟环境是/home/username/Desktop/.pythonenv
现在,注意点.因为它是一个隐藏目录,我必须创建一个符号链接,以便Pycharm"输入"目录.
sudo ln -s /home/yeukhon/Desktop/.pythonenv /home/yeukhon/Desktop/sypythonenv
Run Code Online (Sandbox Code Playgroud)
现在我可以使用这个虚拟环境了.但是,发生了两个问题,我不确定第一个问题是否与第二个问题有关.
A.缺少GTK和GST
这是两个截图.virtualenv python缺少GTK和GST ......我不知道为什么.

B. Django在这个环境中是不可进口的
我尝试在virtualenv(project1)下运行我的Django项目,但我不能.我可以通过终端运行相同的项目.
[yeukhon@localhost ~]$ cd Desktop/djangoapp/project1
[yeukhon@localhost mysite]$ source /home/yeukhon/Desktop/.pythonenv/project1/bin/activate
(project1)[yeukhon@localhost mysite]$ python2.7 manage.py runserver
# I had to use python2.7 instead of python. That's the only problem with terminal here.
Run Code Online (Sandbox Code Playgroud)
题
如何使用我的virtualenv Python解释器在Pycharm中运行它?
#1与#2有关吗?
如何让GTK和GST出现在我的virtualenv中?
感谢您的时间.
quit我.m可以通过命令执行此操作,而不是在我的文件中写入吗?我想在文件执行完成后立即关闭MATLAB.
例如,这是我的命令
matlab -nodisplay < my_script
Run Code Online (Sandbox Code Playgroud)
非常感谢你.
这是我试图做的实际命令
matlab -nodisplay -nodesktop -nosplash -nojvm -r "try, basic_plot;end, quit"
Run Code Online (Sandbox Code Playgroud) 编辑
所以我再次尝试,调用一个新文件test2.py,它的工作原理.我打包了repoman,并且test.py在src文件夹中.我test.py创建并安装后修改了repoman egg.我认为这就是问题所在.但感谢你的帮助.你们认为这是确切的原因吗?
import unittest
import requests
from repoman.core import ultraman, supported
from repoman.ext import writefile,locate_repo
class TestWriteFile(unittest.TestCase):
def setUp(self):
self.username = 'dummy'
self.password = 'dummy'
self.remote = 'http://192.168.1.138:6666/scm/hg/NCL'
def test_scm_permission(self):
"""
Test SCM login.
"""
r = requests.get("http://192.168.1.138:6666/scm/", auth=(self.username, self.password))
self.assertTrue(r.ok)
if __name__ == '__main__':
unittest.main()
Run Code Online (Sandbox Code Playgroud)
运行python test.py我收到此错误:
Traceback (most recent call last):
File "test.py", line 7, in <module>
class TestWriteFile(unittest.TestCase):
File "test.py", line 19, …Run Code Online (Sandbox Code Playgroud) 我通过hex编辑器打开了一个wave文件.我尝试了两个十六进制编辑器,两者都以相反的顺序将44100放入十六进制(AC44).
这是为什么?对于ASCII字符"fmt",排序很自然.

这是AC44.

这与Big-Endian/Little-Endian有关吗?但为什么其他值会以正确的顺序显示?
谢谢!
我在Fedora上这样做
问题:
(sandbox)[root@localhost mysite]# django-admin.py runserver
Error: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings
Run Code Online (Sandbox Code Playgroud)
设置virtualenv
mkdir pythonenv # that's the /home/yeukhon/pythonenv/*.*
cd pythonenv
virtualenv --no-site-packages --distribute sandbox
Run Code Online (Sandbox Code Playgroud)
安装Django
pip install -E sandbox django
# changing mode of /home/yeukhon/pythonenv/sandbox/bin/django-admin.py to 755
# Successfully installed django
Run Code Online (Sandbox Code Playgroud)
在/ home/yeukhon/pythonenv/sandbox下
bin include lib mysite
Run Code Online (Sandbox Code Playgroud)
在lib下
You have /lib/python2.7/site-packages/django/*.*
Run Code Online (Sandbox Code Playgroud)
创建项目很好
(sandbox)[root@localhost sandbox]# django-admin.py startproject mysite
# the path is now /home/yeukhon/pythonenv/sandbox/mysite/*.*
Run Code Online (Sandbox Code Playgroud)
无法运行服务器
django-admin.py runserver
Error: Could not import settings …Run Code Online (Sandbox Code Playgroud) 这是一个例子:
d = dict(a = 2)
print d
{'a': 2}
Run Code Online (Sandbox Code Playgroud)
如何dict()在不编写字符串文字明确性的情况下告诉构造函数使用Unicode u'a'?我正在从一个json默认使用unicode 的模块加载一个字典.我想从现在开始使用unicode.
python ×3
c++ ×2
django ×2
javascript ×2
audio ×1
binary ×1
binary-data ×1
dictionary ×1
fedora ×1
gdb ×1
header ×1
hex ×1
hex-editors ×1
matlab ×1
pycharm ×1
python-2.x ×1
requirejs ×1
static ×1
unicode ×1
unit-testing ×1
variables ×1