Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
各位好 我是今天開始要學習PYTHON的初學者
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 26 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
phanissia2009@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 15 2008, 11:04 am
From: "phanissia2...@gmail.com" <phanissia2...@gmail.com>
Date: Sat, 15 Nov 2008 08:04:08 -0800 (PST)
Local: Sat, Nov 15 2008 11:04 am
Subject: 各位好 我是今天開始要學習PYTHON的初學者
我有一個問題要問各位高手
我是用Python 學習  但是我發現 python 再編寫的時候不能夠 中英文一起使用  例如 :print '哈囉,世界'  這樣
python會錯誤="=
是不是我在安裝的時候還是在設定的時候有出錯??

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Randy Lien  
View profile   Translate to Translated (View Original)
 More options Nov 15 2008, 11:12 am
From: "Randy Lien" <randyl...@gmail.com>
Date: Sun, 16 Nov 2008 00:12:16 +0800
Local: Sat, Nov 15 2008 11:12 am
Subject: Re: [python.tw] 各位好 我是今天開始要學習PYTHON的初學者

檔案要設定編碼哦…在文件最上面加上下面這一句看看
# -*- coding: utf8 -*-

2008/11/16 phanissia2...@gmail.com <phanissia2...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
phanissia2009@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 15 2008, 11:31 am
From: "phanissia2...@gmail.com" <phanissia2...@gmail.com>
Date: Sat, 15 Nov 2008 08:31:51 -0800 (PST)
Local: Sat, Nov 15 2008 11:31 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
我加了  還是不能耶ˊˋ
# -*- coding: utf8 -*-
i=5
print i
i=i+1
print i
s='這是一個字串'
print s
出現錯誤ˊˋ

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
phanissia2009@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 15 2008, 11:33 am
From: "phanissia2...@gmail.com" <phanissia2...@gmail.com>
Date: Sat, 15 Nov 2008 08:33:23 -0800 (PST)
Local: Sat, Nov 15 2008 11:33 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者

On 11月16日, 上午12時31分, "phanissia2...@gmail.com"

<phanissia2...@gmail.com> wrote:
> 我加了  還是不能耶ˊˋ
> # -*- coding: utf8 -*-
> i=5
> print i
> i=i+1
> print i
> s='這是一個字串'
> print s
> 出現錯誤ˊˋ

忘了說  我是使用Vim 7.2編輯的

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jii Chen  
View profile   Translate to Translated (View Original)
 More options Nov 15 2008, 1:36 pm
From: "Jii Chen" <chen...@gmail.com>
Date: Sun, 16 Nov 2008 02:36:39 +0800
Local: Sat, Nov 15 2008 1:36 pm
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

會不會是語系設定問題?
你在 vim 打* :set *或 *:set all* 看看你目前的檔案語系為何,像我的會出現
encoding=utf-8
fileencoding=utf-8

2008/11/16 phanissia2...@gmail.com <phanissia2...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
phanissia2009@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 15 2008, 2:52 pm
From: "phanissia2...@gmail.com" <phanissia2...@gmail.com>
Date: Sat, 15 Nov 2008 11:52:11 -0800 (PST)
Local: Sat, Nov 15 2008 2:52 pm
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
抱歉  我是第一次使用VIM 所以我不知道要怎麼用ˊˋ
拜託大大教我一下   謝謝

On 11月16日, 上午2時36分, "Jii Chen" <chen...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
莊旻儒  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 4:39 am
From: "莊旻儒" <micromi...@gmail.com>
Date: Sun, 16 Nov 2008 17:39:13 +0800
Local: Sun, Nov 16 2008 4:39 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

i=5
print i
i=i+1
print i
s='這是一個字串'
print s
把 s='這是一個字串'  改成  s=u'這是一個字串' 就ok了

我也是新手,我想問的是  難道每一行都要這樣加u 嗎@﹍@??

2008/11/16 phanissia2...@gmail.com <phanissia2...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
micromilua  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 4:48 am
From: micromilua <micromi...@gmail.com>
Date: Sun, 16 Nov 2008 17:48:24 +0800
Local: Sun, Nov 16 2008 4:48 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

應該說 在eclipse +pydev 裡面
如果程式最上面加入了 #-*- coding: UTF-8 -*-

run出來的確是ok

可是 在cmd底下 跑出來還是亂碼

除非把字串加入 u   ex:  s=u'科科'

請問在cmd (big 5)底下要看到正常是不是還要寫啥額外的命令@@??

2008/11/16 莊旻儒 <micromi...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alingo  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 6:57 am
From: alingo <shose...@gmail.com>
Date: Sun, 16 Nov 2008 03:57:06 -0800 (PST)
Local: Sun, Nov 16 2008 6:57 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
這樣子看起來是Terminal設定的問題咧
如果你是用*nix系統的話可以可下#set 或#env檢查一下

我在我的MAC試了一下
只要有加#-*- coding: UTF-8 -*-
是可以看到中文字的

On 11月16日, 下午5時48分, micromilua <micromi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
micromilua  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 7:09 am
From: micromilua <micromi...@gmail.com>
Date: Sun, 16 Nov 2008 20:09:32 +0800
Local: Sun, Nov 16 2008 7:09 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

我是在windows 下開啟的cmd
還是不行@@

繼續嘗試看看  謝謝回覆

2008/11/16 alingo <shose...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alingo  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 7:28 am
From: alingo <shose...@gmail.com>
Date: Sun, 16 Nov 2008 04:28:11 -0800 (PST)
Local: Sun, Nov 16 2008 7:28 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
在windows要用
#-*- coding: cp950 -*-

話說回頭encoding真的是個惱人的東東

On 11月16日, 下午8時09分, micromilua <micromi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
phanissia2009@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 7:44 am
From: "phanissia2...@gmail.com" <phanissia2...@gmail.com>
Date: Sun, 16 Nov 2008 04:44:51 -0800 (PST)
Local: Sun, Nov 16 2008 7:44 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
可以了耶   可是這樣變的好麻煩喔ˊˋ
是VIM本身的問題嗎??  還是PYTHON就是這樣??  不能像JAVA一樣直接中英文混著編寫??  還是 是我白痴不會用= =??

On 11月16日, 下午8時28分, alingo <shose...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zoom. Quiet  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 7:59 am
From: Zoom.Quiet <zoom.qu...@gmail.com>
Date: Sun, 16 Nov 2008 20:59:58 +0800
Local: Sun, Nov 16 2008 7:59 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者
2008/11/16 alingo <shose...@gmail.com>:
> 在windows要用
> #-*- coding: cp950 -*-

千万别! 用个靠谱的编辑器,在任何地方使用utf-8 是一劳永逸的好习惯,,,

--
http://zoomquiet.org'''
过程改进乃是催生可促生靠谱的人的组织!
PE keeps evolving organizations which promoting people be good!'''
[HR]金山软件常年招聘大量Py/C++人才!
https://groups.google.com/group/python-cn/web/ot-py-c
简历直投俺就好;-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
micromilua  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 8:00 am
From: micromilua <micromi...@gmail.com>
Date: Sun, 16 Nov 2008 21:00:46 +0800
Local: Sun, Nov 16 2008 8:00 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

XD
我剛剛一直鑽牛角尖
cmd -> chcp 65001

原來就差這麼一點點

謝謝alingoㄜ的教學
2008/11/16 alingo <shose...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
micromilua  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 8:04 am
From: micromilua <micromi...@gmail.com>
Date: Sun, 16 Nov 2008 21:04:15 +0800
Local: Sun, Nov 16 2008 8:04 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

應該說還是都宣告成 utf-8 不過
如果在windows裡面要用的話 就 chcp 950來看

目前我想到的解決方法是這樣  說不定還是有code可以弄出一勞永逸的方法

不過我是新手@@ 還請大家開示一下

2008/11/16 micromilua <micromi...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kaiching  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 9:51 am
From: kaiching <kaichi...@gmail.com>
Date: Sun, 16 Nov 2008 06:51:14 -0800 (PST)
Local: Sun, Nov 16 2008 9:51 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者

Windows 下如要宣告成 UTF-8
*.py 的 Python 執行檔要儲存為 ASCII 編碼(依記事本的方式,其實是Big5,Windows預設的編碼格式)
可參考 http://pydoing.blogspot.com/2008/10/blog-post_9393.html

On 11月16日, 下午9時04分, micromilua <micromi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alingo  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 10:27 am
From: alingo <shose...@gmail.com>
Date: Sun, 16 Nov 2008 07:27:29 -0800 (PST)
Local: Sun, Nov 16 2008 10:27 am
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
嗯我也認同zoom的講法
用utf-8才是治本之道
不過這樣一來
似乎在windows console下測有中文的python script就不是很方便了

TOO BAD ;(

On 11月16日, 下午9時04分, micromilua <micromi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zoom. Quiet  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 10:35 am
From: Zoom.Quiet <zoom.qu...@gmail.com>
Date: Sun, 16 Nov 2008 23:35:22 +0800
Local: Sun, Nov 16 2008 10:35 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者
2008/11/16 alingo <shose...@gmail.com>:
> 嗯我也認同zoom的講法
> 用utf-8才是治本之道
> 不過這樣一來
> 似乎在windows console下測有中文的python script就不是很方便了

Sygwin
或是其它 替代品!

> TOO BAD ;(

--
http://zoomquiet.org'''
过程改进乃是催生可促生靠谱的人的组织!
PE keeps evolving organizations which promoting people be good!'''
[HR]金山软件常年招聘大量Py/C++人才!
https://groups.google.com/group/python-cn/web/ot-py-c
简历直投俺就好;-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tiberius Teng  
View profile   Translate to Translated (View Original)
 More options Nov 16 2008, 10:41 am
From: "Tiberius Teng" <tiberius.t...@gmail.com>
Date: Sun, 16 Nov 2008 23:41:11 +0800
Local: Sun, Nov 16 2008 10:41 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

打開 Python25\Lib\site.py

找 def setencoding():

把 # Enable to support locale aware default string encodings 上面的 if 0: 改成 if
1:

然後下面的 # Enable to switch off ... 的 if 1: 改成 if 0:

收工, 往後檔案用 utf8 照樣可以直接 print 出來 ;)

2008/11/16 alingo <shose...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
micromilua  
View profile  
 More options Nov 17 2008, 6:18 am
From: micromilua <micromi...@gmail.com>
Date: Mon, 17 Nov 2008 19:18:32 +0800
Local: Mon, Nov 17 2008 6:18 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

抱歉 我是用Python26
按照上面說得改了

===================================================

def setencoding():
    """Set the string encoding used by the Unicode implementation.  The
    default is 'ascii', but if you're willing to experiment, you can
    change this."""
    encoding = "ascii" # Default value set by _PyUnicode_Init()
    if 1:
        # Enable to support locale aware default string encodings.
        import locale
        loc = locale.getdefaultlocale()
        if loc[1]:
            encoding = loc[1]
    if 0:
        # Enable to switch off string to Unicode coercion and implicit
        # Unicode to string conversion.
        encoding = "undefined"
    if encoding != "ascii":
        # On Non-Unicode builds this will raise an AttributeError...
        sys.setdefaultencoding(encoding) # Needs Python Unicode build !
===================================================

test code

==========
#-*- coding: utf-8 -*-

print '科科'
==========

存檔編碼,我是在記事本選utf8

print出來的結果

蝘?

如果換成 print u'科科'

就可以了@@

下面是我google到的網頁 跟上述的差不多

http://heaven.branda.to/~thinker/GinGin_CGI.py/show_id_doc/190

請問是否有人可以解決我的疑惑嗎~?感謝!!
2008/11/16 Tiberius Teng <tiberius.t...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
micromilua  
View profile   Translate to Translated (View Original)
 More options Nov 17 2008, 6:53 am
From: micromilua <micromi...@gmail.com>
Date: Mon, 17 Nov 2008 19:53:35 +0800
Local: Mon, Nov 17 2008 6:53 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

再補充一下
在eclispe裡面的console端 print是ok
但是我chcp 65001 (unicode) 後執行也是亂碼
把檔案編碼存成ansi就可以正常顯示(in 記事本)
所以我們用eclispe寫程式的時候 到底該編碼成ansi還是utf8??

2008/11/17 micromilua <micromi...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tiberius Teng  
View profile   Translate to Translated (View Original)
 More options Nov 17 2008, 7:44 am
From: "Tiberius Teng" <tiberius.t...@gmail.com>
Date: Mon, 17 Nov 2008 20:44:33 +0800
Local: Mon, Nov 17 2008 7:44 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

這樣是正確的行為
你沒加 u 的話, python 會把它當成 raw binary data 直接送
如果 script source 用的編碼跟執行時的系統不一樣就會爆

加 u 的話, python 會照檔首的設定把字串解成 unicode
輸出時再動態轉換成系統目前使用的 encoding (如果它有辦法知道的話 ...)

windows 的 console 實在很 !@#$%^ ... 盡量別用它測 unicode 或是顯示資料 ...

只要是「文字資料」最好就用 unicode 來存
雖然說起來, 這種東西甚至不該出現在程式碼裡 XD
gettext message catalog 才是它們該去的地方

2008/11/17 micromilua <micromi...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tiberius Teng  
View profile   Translate to Translated (View Original)
 More options Nov 17 2008, 7:46 am
From: "Tiberius Teng" <tiberius.t...@gmail.com>
Date: Mon, 17 Nov 2008 20:46:02 +0800
Local: Mon, Nov 17 2008 7:46 am
Subject: Re: [python.tw] Re: 各位好 我是今天開始要學習PYTHON的初學者

這一句就是在說 eclipse -_-
它執行 script 的時候是把輸出內容當成 utf-8 來解
但是完全沒有設定相關的 environ
所以這邊能動, 很可能只是運氣好, 拿到其它系統上就炸了 ...

2008/11/17 Tiberius Teng <tiberius.t...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gasolin@gmail.com  
View profile   Translate to Translated (View Original)
 More options Nov 17 2008, 8:11 pm
From: "gaso...@gmail.com" <gaso...@gmail.com>
Date: Mon, 17 Nov 2008 17:11:28 -0800 (PST)
Local: Mon, Nov 17 2008 8:11 pm
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
是不是用的編輯器預設不是 utf-8 (例如 windows notepad),
先用 python 內建的 IDLE 試試.

ok 的話建議抓 ulipad 或 easyeclipse python 版 (pydev+eclipse) 來用.

--
為什麼會想不開在 windows 上用 vim 哩....


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
yungyuc  
View profile   Translate to Translated (View Original)
 More options Nov 22 2008, 3:15 pm
From: yungyuc <yung...@gmail.com>
Date: Sat, 22 Nov 2008 12:15:43 -0800 (PST)
Local: Sat, Nov 22 2008 3:15 pm
Subject: Re: 各位好 我是今天開始要學習PYTHON的初學者
應該說,Windows command line 爛到爆,只要是 non-ASCII 都很麻煩。

千萬別再用 Big5/cp950 了。

On Nov 16, 10:27 am, alingo <shose...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 26   Newer >
« Back to Discussions « Newer topic     Older topic »